<template>
  <div>
    <!-- 黄鹤楼 2010-2021期间 每年接待游客人数 -->
    <Echart :options="options" id="total-chart" height="320px" width="100%">
    </Echart>
  </div>
</template>

<script>
import Echart from "@/common/echart";
export default {
  data() {
    return {
      options: {},
    };
  },
  components: {
    Echart,
  },
  props: {
    cdata: {
      type: Object,
      default: () => ({}),
    },
  },
  watch: {
    cdata: {
      handler(newData) {
        this.options={
          tooltip: {
            trigger: "axis",
            backgroundColor: "rgba(255,255,255,0.1)",
            axisPointer: {
              type: "shadow",
              label: {
                show: true,
                backgroundColor: "#00BFFF",
              },
            },
            textStyle: {
              color: "#fff",
            },
            formatter: function(arg) {
              let str=arg[0].name+"<br/>";
              arg.forEach((item,idx) => {
                str+=`${item.marker}${item.seriesName}: `;
                str+=Number(item.data)+"万人次";
                str+=idx===arg.length-1? "":"<br/>";
              });
              return str;
            },
          },
          legend: {
            data: ["接待游客人数"],
            textStyle: {
              color: "#B4B4B4",
            },
            top: "0%",
          },
          grid: {
            top: "8%",
            left: "12%",
          },
          xAxis: {
            data: newData.category,
            axisLine: {
              lineStyle: {
                color: "#B4B4B4",
              },
            },
            axisTick: {
              show: false,
            },
          },
          yAxis: [
            {
              max: 500,
              min: 100,
              interval: 50,
              splitLine: { show: false },
              axisLine: {
                lineStyle: {
                  color: "#B4B4B4",
                },
              },
              axisLabel: {
                formatter: "{value} ",
              },
            },
          ],
          series: [
            {
              name: "接待游客人数",
              type: "line",
              smooth: true,
              showAllSymbol: true,
              symbol: "emptyCircle",
              symbolSize: 8,
               
              itemStyle: {
                color: "#00BFFF",
              },
              data: newData.lineData,
            },
          ],
        };
      },
      immediate: true,
      deep: true,
    },
  },
};
</script>
